package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

class znn extends zagm {
   DataBar a;

   public znn(DataBar var1, zaay var2, zfv var3, CellArea var4) {
      super(var2, var3, var4);
      this.a = var1;
      var1.getMaxCfvo().setValue(this.a(var1.getMaxCfvo()).k());
      var1.getMinCfvo().setValue(this.a(var1.getMinCfvo()).k());
   }

   public com.aspose.cells.a.d.zb a(com.aspose.cells.b.a.b.zq var1, double[] var2, int var3, int var4) {
      if (this.c == null) {
         this.d();
      }

      if (this.c.b() != 3) {
         return null;
      } else {
         new ArrayList();
         double var6 = (Double)this.a.getMaxCfvo().getValue();
         double var8 = (Double)this.a.getMinCfvo().getValue();

         try {
            float var10 = 0.0F;
            double var11 = ((zyy)this.c).k();
            if (var6 == var8) {
               if (var6 == 0.0D) {
                  var10 = 0.0F;
               } else if (var11 == var6) {
                  if (this.a.getMaxCfvo().getType() == 6 && this.a.getMinCfvo().getType() == 7) {
                     var10 = 1.0F;
                  } else {
                     var10 = 0.5F;
                  }
               } else if (var11 > var6) {
                  var10 = 1.0F;
               } else {
                  var10 = 0.0F;
               }
            } else if (var8 >= 0.0D) {
               var10 = (float)(var11 / var6);
               if (this.a.getAxisPosition() == 1) {
                  var10 /= 2.0F;
               }
            } else if (var6 <= 0.0D) {
               var10 = (float)(Math.abs(var11) / Math.abs(var8));
               if (this.a.getAxisPosition() == 1) {
                  var10 /= 2.0F;
               }
            } else {
               switch(this.a.getAxisPosition()) {
               case 0:
                  var10 = (float)(Math.abs(var11) / (var6 - var8));
                  break;
               case 1:
                  double var13 = Math.max(Math.abs(var8), Math.abs(var6));
                  var10 = (float)(Math.abs(var11) / var13 / 2.0D);
                  break;
               case 2:
                  var10 = (float)((var11 - var8) / (var6 - var8));
                  break;
               default:
                  var10 = (float)(Math.abs(var11) / (var6 - var8));
               }
            }

            var10 = (var10 * (float)(this.a.getMaxLength() - this.a.getMinLength()) + (float)this.a.getMinLength()) / 100.0F;
            if (var10 > (float)this.a.getMaxLength() / 100.0F) {
               var10 = (float)this.a.getMaxLength() / 100.0F;
            }

            if (var10 < (float)this.a.getMinLength() / 100.0F) {
               var10 = (float)this.a.getMinLength() / 100.0F;
            }

            Color var25;
            if (var11 >= 0.0D) {
               var25 = Color.a(255, (Color)this.a.getColor());
            } else if (this.a.getNegativeBarFormat().getColorType() == 1) {
               var25 = Color.a(255, (Color)this.a.getColor());
            } else {
               var25 = Color.a(255, (Color)this.a.getNegativeBarFormat().getColor());
            }

            Color var14 = Color.fromArgb(255, 255, 255, 255);
            int var15 = this.a.getDirection();
            if (var15 == 0) {
               if (this.b.d.getDisplayRightToLeft()) {
                  var15 = 2;
               } else {
                  var15 = 1;
               }
            }

            float var16 = 0.0F;
            if (var8 < 0.0D && var6 > 0.0D) {
               if (this.a.getAxisPosition() == 0) {
                  if (var15 == 2) {
                     var16 = (float)(var6 / (var6 - var8));
                  } else {
                     var16 = (float)(Math.abs(var8) / (var6 - var8));
                  }
               } else if (this.a.getAxisPosition() == 1) {
                  var16 = 0.5F;
               }
            } else if (var8 >= 0.0D) {
               if (var15 == 2) {
                  var16 = 1.0F;
               } else {
                  var16 = 0.0F;
               }

               if (this.a.getAxisPosition() == 1) {
                  var16 = 0.5F;
               }
            } else if (var6 <= 0.0D) {
               if (var15 == 2) {
                  var16 = 0.0F;
               } else {
                  var16 = 1.0F;
               }

               if (this.a.getAxisPosition() == 1) {
                  var16 = 0.5F;
               }
            }

            ArrayList var18 = null;
            com.aspose.cells.a.d.zb var19 = new com.aspose.cells.a.d.zb();
            com.aspose.cells.b.a.b.zq var17;
            com.aspose.cells.a.d.zn var20;
            if (var8 < 0.0D && var6 > 0.0D && this.a.getAxisPosition() != 2) {
               if (var15 == 2 && var11 >= 0.0D || var15 == 1 && var11 < 0.0D) {
                  var17 = new com.aspose.cells.b.a.b.zq(new com.aspose.cells.b.a.b.zo(var1.d().d() + var1.h() * var16 - var1.h() * var10, var1.d().e() + 1.0F), new com.aspose.cells.b.a.b.zt(var1.h() * var10, var1.i() - 2.0F));
                  if (this.a.getBarFillType() == 0) {
                     var20 = new com.aspose.cells.a.d.zn(var17);
                     var20.a((com.aspose.cells.b.a.b.zc)(new com.aspose.cells.b.a.b.zu(var25)));
                     var19.a((com.aspose.cells.a.d.zl)var20);
                  } else {
                     var18 = com.aspose.cells.a.d.zh.a(var14, var25, var17, 5, 1);
                  }
               } else {
                  var17 = new com.aspose.cells.b.a.b.zq(new com.aspose.cells.b.a.b.zo(var1.d().d() + var1.h() * var16, var1.d().e() + 1.0F), new com.aspose.cells.b.a.b.zt(var1.h() * var10, var1.i() - 2.0F));
                  if (this.a.getBarFillType() == 0) {
                     var20 = new com.aspose.cells.a.d.zn(var17);
                     var20.a((com.aspose.cells.b.a.b.zc)(new com.aspose.cells.b.a.b.zu(var25)));
                     var19.a((com.aspose.cells.a.d.zl)var20);
                  } else {
                     var18 = com.aspose.cells.a.d.zh.a(var25, var14, var17, 5, 1);
                  }
               }
            } else if (var15 == 2 && var11 >= 0.0D || var11 < 0.0D && (var15 == 2 && this.a.getAxisPosition() == 2 || var15 == 1 && this.a.getAxisPosition() != 2)) {
               var17 = new com.aspose.cells.b.a.b.zq(new com.aspose.cells.b.a.b.zo(var1.d().d() + var1.h() * var16 - var1.h() * var10, var1.d().e() + 1.0F), new com.aspose.cells.b.a.b.zt(var1.h() * var10, var1.i() - 2.0F));
               if (this.a.getBarFillType() == 0) {
                  var20 = new com.aspose.cells.a.d.zn(var17);
                  var20.a((com.aspose.cells.b.a.b.zc)(new com.aspose.cells.b.a.b.zu(var25)));
                  var19.a((com.aspose.cells.a.d.zl)var20);
               } else {
                  var18 = com.aspose.cells.a.d.zh.a(var14, var25, var17, 5, 1);
               }
            } else {
               var17 = new com.aspose.cells.b.a.b.zq(new com.aspose.cells.b.a.b.zo(var1.d().d() + var1.h() * var16, var1.d().e() + 1.0F), new com.aspose.cells.b.a.b.zt(var1.h() * var10, var1.i() - 2.0F));
               if (this.a.getBarFillType() == 0) {
                  var20 = new com.aspose.cells.a.d.zn(var17);
                  var20.a((com.aspose.cells.b.a.b.zc)(new com.aspose.cells.b.a.b.zu(var25)));
                  var19.a((com.aspose.cells.a.d.zl)var20);
               } else {
                  var18 = com.aspose.cells.a.d.zh.a(var25, var14, var17, 5, 1);
               }
            }

            com.aspose.cells.a.d.zn var21;
            Color var26;
            if (this.a.getBarBorder().getType() == 1 && var10 > 0.0F) {
               if (var11 >= 0.0D) {
                  var26 = Color.a(255, (Color)this.a.getBarBorder().getColor());
               } else if (this.a.getNegativeBarFormat().getBorderColorType() == 1) {
                  var26 = Color.a(255, (Color)this.a.getBarBorder().getColor());
               } else {
                  var26 = Color.a(255, (Color)this.a.getNegativeBarFormat().getBorderColor());
               }

               var21 = new com.aspose.cells.a.d.zn(var17);
               var21.a = new com.aspose.cells.a.d.zs(var26, 1.0F * (float)var2[0]);
               var19.a((com.aspose.cells.a.d.zl)var21);
            }

            var19.a(new com.aspose.cells.a.d.zn(var1));
            if (var18 != null) {
               Iterator var28 = var18.iterator();

               while(var28.hasNext()) {
                  var21 = (com.aspose.cells.a.d.zn)var28.next();
                  var19.a((com.aspose.cells.a.d.zl)var21);
               }
            }

            if (var16 > 0.0F && var16 < 1.0F && this.a.getAxisPosition() != 2) {
               var26 = Color.a(255, (Color)this.a.getAxisColor());
               com.aspose.cells.a.d.zs var27 = new com.aspose.cells.a.d.zs(var26, 1.0F * (float)var2[0]);
               var27.i = 0;
               var27.a(new float[]{1.0F, 1.0F});
               float var22 = var1.d().d() + var1.h() * var16;
               com.aspose.cells.a.d.zk var23 = new com.aspose.cells.a.d.zk(var22, var1.d().e(), var22, var1.d().e() + var1.i(), var27);
               var19.a((com.aspose.cells.a.d.zl)var23);
            }

            return var19;
         } catch (Exception var24) {
            return null;
         }
      }
   }

   public boolean c() {
      return this.a.getShowValue();
   }
}
